// map.js
var util = require('../../utils/util.js')

let width = util.getScreenWidth();
console.log("-----++-----");
console.log(width);
let height = width * 0.7;

console.log(width)

Page({
  data: {
    screenWidth: width,
    mapHeight: height,
    gymnasiumHeight: width * 67/375,
    locationIfoHeight: width * 44 / 375,
    photoHeight: width * 100 / 375,
    photoImagesArr: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
  
  
    locationIfo:"距您约2.1千米,民港区船东大道320",
    telephoneNum:18516771636,
    mark_star:4,
    nochooseMark_star: 1,
    //控制图片浏览器
    showModalStatus:false,
    scale: 13,
    latitude: "",
    longitude: "",
    markers: [],
    controls: [{
      id: 1,
      iconPath: '../../images/location.png',
      position: {
        left: 320,
        top: 100 - 50,
        width: 20,
        height: 20
      },
      clickable: true,
      
    },
    {
      id: 2,
      iconPath: '../../images/location.png',
      position: {
        left: 340,
        top: 100 - 50,
        width: 20,
        height: 20
      },
      clickable: true
    }
    ],
    circles: []

  },

  onLoad: function () {
    var _this = this;
   
    wx.getSystemInfo({
      success: function (res) {
        //设置map高度，根据当前设备宽高满屏显示
        _this.setData({

          view: {
            Height: res.windowHeight
          },
        
     
        })

  console.log("=======================")

  
      }
    })

    wx.getLocation({
      type: 'wgs84', // 默认为 wgs84 返回 gps 坐标，gcj02 返回可用于 wx.openLocation 的坐标
      success: function (res) {

        _this.setData({
          latitude: res.latitude,
          longitude: res.longitude,
          markers: [{
            id: "1",
            latitude: res.latitude,
            longitude: res.longitude,
            width: 50,
            height: 50,
            iconPath: "../../images/location.png",
           // title: "我的位置",
            callout: { content: 'das', color: '#333333', fontSize: 12, borderRadius: 20, bgColor: "#ffffff", padding: 20, display:"ALWAYS" }
            
            

          }],
          circles: [{
            latitude: res.latitude,
            longitude: res.longitude,
            color: '#7cb5ec88',
            fillColor: '#7cb5ec88',
            radius: 2000,
            strokeWidth: 1
          }]

        })
      }

    })

  },

  regionchange(e) {
    console.log("regionchange===" + e.type)
  },

  //点击merkers
  markertap(e) {
    console.log(e.markerId)

    wx.showActionSheet({
      itemList: ["A"],
      success: function (res) {
        console.log(res.tapIndex)
      },
      fail: function (res) {
        console.log(res.errMsg)
      }
    })
  },

  //点击缩放按钮动态请求数据
  controltap(e) {
    var that = this;
    console.log("scale===" + this.data.scale)
    if (e.controlId === 1) {
      // if (this.data.scale === 13) {
      that.setData({
        scale: --this.data.scale
      })
      // }
    } else {
      //  if (this.data.scale !== 13) {
      that.setData({
        scale: ++this.data.scale
      })
      // }
    }


  },
  Person() {
    this.id = "111";
    this.name = "222";
    this.age = "333";
  } ,
  // 图片点击
  clickImage:function(e){
    console.log(e.currentTarget.dataset.areaid)
    let url = e.currentTarget.dataset.areaid
    let index = 0
    for (let i = 0; i < this.data.photoImagesArr.length;i ++ ){

      if (this.data.photoImagesArr[i] == url){

        index = i;

      }

   
    }
    console.log(index)
    var photoInf = {
      photoImagesArr: this.data.photoImagesArr,
      
      index: index
    } 
    wx.navigateTo({
      url: '../../pages/pictureScan/pictureScan?photoInf=' + JSON.stringify(photoInf),
    })
    


    
  },
  


  

})
